const initialState = {
    chatlog: ['学react', '学redux'],
    status: true,
    nickname: '卢本伟'
}

const chat = (state = initialState, action) => {
    let { type, payload } = action;
    switch (type) {
        case "ADD_CHAT":
            return Object.assign({}, state, {
                chatlog: [payload, ...state.chatlog]
            })

        case "CHANGE_NAME":
            return Object.assign({}, state, {
                nickname: payload
            })

        case "CHANGE_STATUS":
            return Object.assign({}, state, {
                status: !state.status
            })
        default:
            return { ...state }
    }
}

export default chat